package com.yunhui.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunhui.entity.Merchant;
import com.yunhui.mapper.MerchantMapper;
import com.yunhui.service.MerchantService;


import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  商家的业务处理的层实现类
 * </p>
 *
 * @author WGH
 * @since 2019-12-09
 */
@Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements MerchantService {

    @Resource
    private MerchantMapper merchantMapper;


    /**
     * 注册
     * @param account
     * @param phone
     * @param eamil
     * @param password
     * @return
     */
    @Override
    public int insertMerchant(String account, String merchantname, String phone, String eamil,
                              String imgUrl, Date createDate, Integer status, String password) {
        return merchantMapper.insertMerchant(account,merchantname,phone,eamil,imgUrl,createDate,status,password);
    }

    /**
     * 登录
     * @param username
     * @param password
     * @return
     */
    public Merchant businessLogin(String username,String phone,String eamil,String password){
        return merchantMapper.businessLogin(username,phone,eamil,password);
    }

    /**
     * 商家列表
     * @param
     * @return
     */
    @Override
    public List<Merchant> businessList() {
        return merchantMapper.businessList();
    }


    /**
     * 根据ID查询详情
     * @param id
     * @return
     */
    @Override
    public Merchant businessAndId(Integer id) {
        return merchantMapper.businessAndId(id);
    }


    /**
     * count
     * @return
     */
    @Override
    public Integer findCount() {
        return merchantMapper.findCount();
    }


    /**
     * 分页
     * @param Size
     * @param pageIndex
     * @param merchantname
     * @return
     */
    @Override
    public List<Merchant> findPage(int Size,int pageIndex,String merchantname) {
        int num = (Size-1)*pageIndex;
        return merchantMapper.findPage(num,pageIndex,merchantname);
    }





    /**
     * 状态 — 审批
     * @param status
     * @return
     */
    @Override
    public Integer businessAndStatus(Integer status,Integer id) {
        Merchant merchant = new Merchant();
        merchant.setId(id);
        merchant.setStatus(status);
        return merchantMapper.businessAndStatus(merchant.getStatus(),merchant.getId());
    }












}
